import test0ne.TreeNode;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;
import java.util.concurrent.LinkedBlockingQueue;

public class BinaryTree {

    private static Queue<TreeNode> queue = new LinkedBlockingQueue<>();

    private static void traverse(TreeNode root) {
        /**
         * 前序
         */
        traverse(root.left);
        /**
         * 中序
         */
        traverse(root.right);
        /**
         * 后序
         */
    }

    private static void seqTree(TreeNode root) {
        if(root == null) {
            return;
        }
        queue.add(root);
        while (!queue.isEmpty()) {
            TreeNode one = queue.poll();
            System.out.println(one.val);

            TreeNode left = one.left;
            TreeNode right = one.right;
            if(left != null) {
                queue.add(left);
            }
            if(right != null) {
                queue.add(right);
            }
        }
    }

    public static void main(String[] args) throws ClassNotFoundException {
        TreeNode treeNode = new TreeNode(1);
        treeNode.left = new TreeNode(2);
        treeNode.right = new TreeNode(3);
        treeNode.left.left = new TreeNode(4);
        treeNode.left.right = new TreeNode(5);

        treeNode.right.left = new TreeNode(6);
        treeNode.right.right = new TreeNode(7);

        LinkedList linkedList = new LinkedList();
//        seqTree(treeNode);

        Class clazz = Class.forName(BinaryTree.class.getName());
        //获取所有属性
        Field[] fields = clazz.getDeclaredFields();
        for (Field field : fields) {
            System.out.print(field.getAnnotatedType());
            System.out.println(field.getName());
        }

        //
        Method[] methods = clazz.getMethods();
        for (Method method : methods) {
            System.out.println(method.getName());
            System.out.println(method.getReturnType());
        }

        //
    }

}
